class MyHeader extends HTMLElement {
  constructor() {
    super()
    const shadow = this.attachShadow({ mode: "open" })
    let _data = {
      title: this.getAttribute("title") || "",
    }
    this.render(shadow, _data)
  }

  render(shadow, data) {
    let style = document.createElement("style")
    style.innerHTML = `
      @import url("http://at.alicdn.com/t/c/font_3828430_140r7z3i943g.css");

      .container {
        display: flex;
        padding-left: 50px;
        background-color: var(--color-primary);
        color: #fff;
        height: 50px;
        align-items: center;
        gap: 100px;
      }
      .header {
        font-size: 18px;
        font-weight: bold;
      }
      .header .iconfont {
        font-weight: normal;

      }
    `

    let container = document.createElement("div")
    container.className = "container"
    container.innerHTML = `
      <div class="header">
        <i class="iconfont icon-bangzhu"></i>
        <span class="header-text">问卷管理</span>
      </div>
      <div class="title">${data.title}</div>
    `
    shadow.appendChild(style)
    shadow.appendChild(container)
  }
}

customElements.define("my-header", MyHeader)

export default MyHeader
